package ro.ubbcluj.cs.bs.api.assembler;

import ro.ubbcluj.cs.bs.backend.model.Author;
import ro.ubbcluj.cs.bs.common.dto.AuthorDto;

/**
 * Created by Levente on 2014.05.21..
 */
public class AuthorAssembler implements Assembler<Author, AuthorDto> {
    @Override
    public Author createModel() {
        return new Author();
    }

    @Override
    public AuthorDto createDto() {
        return new AuthorDto(Author.class.getName());
    }

    @Override
    public AuthorDto modelToDto(Author model) {
        AuthorDto dto = createDto();
        dto.setId(model.getId());
        dto.setFirstName(model.getFirstName());
        dto.setLastName(model.getLastName());
        return dto;
    }

    @Override
    public Author dtoToModel(AuthorDto dto) {
        Author model = createModel();
        model.setId(dto.getId());
        model.setFirstName(dto.getFirstName());
        model.setLastName(dto.getLastName());
        return model;
    }
}
